package org.erepublik.company.scanner;

import java.util.HashMap;

import org.erepublik.company.ECountry;
import org.erepublik.company.EProductType;
import org.erepublik.company.Taxes;
import org.erepublik.company.service.InternetVatService;

/**
 * Program skanuje podatki z internetu i wyswietla je w formie xml'a
 *
 * @author Kacper Gorski 'Railman' railman85@gmail.com
 */
public class TaxesScanner {

    /**
     * @param args
     */
    public static void main(String[] args) {

        InternetVatService service = new InternetVatService();
        HashMap<ECountry, Taxes> taxes = null;
        try {
            taxes = service.getVat();
        } catch (Exception e) {
            e.printStackTrace();

        }
        ECountry[] country = ECountry.values();
        EProductType[] products = EProductType.values();
        for (int i = 0; i < country.length; i++) {
            System.out.println("<CountryTax country=\""+country[i]+"\">");
            for (int j = 0; j < products.length; j++) {
                System.out.println("<productTax>");
                
                System.out.println("<product>"+products[j]+"</product>");
                System.out.println("<vat>"+Math.round( taxes.get(country[i]).getVat(products[j])*100.0d)+"</vat>");
                System.out.println("<importTax>"+Math.round( taxes.get(country[i]).getImportTax(products[j])*100.0d )+"</importTax>");
                System.out.println("<incomeTax>"+Math.round( taxes.get(country[i]).getIncomeTax(products[j])*100.0d )+"</incomeTax>");
                
                System.out.println("</productTax>");
            }
            System.out.println("</CountryTax>");

        }

    }

}
